// 入口文件
const express = require('express')
const app = express()
app.use(require('cors')())
// 需要使用req.body => 将数据转成json
app.use(express.json())
// 设置加密算法
app.set('pwd', 'qwe123')

// 连接mongoose数据库
require('./plugins/db')(app)
const Category = require('./models/Category')

// 加载admin路由配置
require('./routes/admin/index')(app)
require('./routes/web/index')(app)

// 静态资源托管
app.use('/uploads', express.static(__dirname + '/uploads'))
app.use('/admin', express.static(__dirname + '/admin'))
app.use('/web', express.static(__dirname + '/web'))

app.listen(3000, () => {
    console.log('http://localhost:3000');
})
